#include<bits/stdc++.h>
using namespace std;
#define ll long long

class Solution {
    public:
        int mySqrt(int x) {
                int l=1;
                int r=x;
                while(l<=r){
                    int mid=l+(r-l)/2;
                    if(mid<=x/mid){
                        l=mid+1;
                    }else{
                        r=mid-1;
                    }
                }
                return r;
            }
    };


